/*
 * p4454.cpp
 *
 *  Created on: 2013-10-27
 *      Author: zy
 */
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
const double eps = 1e-8;
const double PI = acos(-1.0);
double dem = 1e-4;

double r;
double sig(double d)
{
	return fabs(d) < eps ? 0 : d < 0 ? -1 : 1;
}
struct Point
{
	double x, y;
	Point friend operator -(Point a, Point b)
	{
		Point ans;
		ans.x = a.x - b.x;
		ans.y = a.y - b.y;
		return ans;
	}
	double mod()
	{
		return sqrt(x * x + y * y);
	}
	void read()
	{
		scanf("%lf%lf", &x, &y);
	}
};
Point rec[4];
Point s, c;
double cross(Point o, Point a, Point b)
{
	return (a.x - o.x) * (b.x - o.x) + (a.y - o.y) * (b.y - o.y);
}
double dot(Point o, Point a, Point b)
{
	return (a.x - o.x) * (b.x - o.x) + (a.y - o.y) * (b.y - o.y);
}
double dot(Point a, Point b)
{
	return a.x * b.x + a.y * b.y;
}
double dis(Point a, Point b)
{
	return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int btw(Point x, Point a, Point b)
{
	return sig(dot(x, a, b));
}
double cross(Point a, Point b)
{
	return a.x * b.y - a.y * b.x;
}
double disToSeg(Point p, Point a, Point b)
{
	Point v1 = b - a, v2 = p - a, v3 = p - b;
	if (sig(dot(v1, v2)) < 0)
		return v2.mod();
	else if (sig(dot(v1, v3) > 0))
		return v3.mod();
	else
		return fabs(cross(v1, v2) / v1.mod());
}
double f(double the)
{
	Point mid;
	mid.x = r * cos(the);
	mid.y = r * sin(the);
	double m1 = min(disToSeg(mid, rec[0], rec[2]),
			disToSeg(mid, rec[0], rec[3]));
	double m2 = min(disToSeg(mid, rec[1], rec[2]),
			disToSeg(mid, rec[1], rec[3]));
	return dis(mid, s) + min(m1, m2);
}

int main()
{

	while (true)
	{
		s.read();
		if (sig(s.mod()) == 0)
			break;
		c.read();
		scanf("%lf", &r);
		rec[0].read();
		rec[1].read();
		s = s - c;
		rec[0] = rec[0] - c;
		rec[1] = rec[1] - c;
		rec[2].x = rec[0].x;
		rec[2].y = rec[1].y;
		rec[3].x = rec[1].x;
		rec[3].y = rec[0].y;
		double l = 0;
		double r = PI;
		double ans = 1e18;
		while (r - l > dem)
		{
			double m1 = l + (r - l) / 3;
			double m2 = r - (r - l) / 3;
			if (f(m1) < f(m2))
				r = m2;
			else
				l = m1;
		}
		ans = min(ans, f(l));
		l = PI;
		r = 2 * PI;
		while (r - l > dem)
		{
			double m1 = l + (r - l) / 3;
			double m2 = r - (r - l) / 3;
			if (f(m1) < f(m2))
				r = m2;
			else
				l = m1;
		}
		ans = min(ans, f(l));
		printf("%0.2lf\n", ans);
	}
	return 0;
}
